/**
 * 
 */
package com.demo2do.strawberry.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.core.web.interceptor.MenuSetting;
import com.demo2do.strawberry.entity.investor.Institution;
import com.demo2do.strawberry.service.InstitutionService;

/**
 * @author lute
 *
 */
@Controller
@RequestMapping("signup")
@MenuSetting("signup")
public class SignupController {
	
	@Autowired
	private InstitutionService institutionService;
	
	/**
	 * @param id
	 * @return
	 */
	@RequestMapping("")
	public ModelAndView createInvestor(@RequestParam(value = "institution", required = false) Long id) {
		
		ModelAndView modelAndView = new ModelAndView("signup/signup-investor");
		if(id != null) {
			Institution selectedInstitution = institutionService.load(id);
			modelAndView.addObject("selectedInstitution", selectedInstitution);
		}
		
		List<Institution> institutions = institutionService.loadAll();
		modelAndView.addObject("institutions", institutions);
		return modelAndView;
	}
	
	/**
	 * @return
	 */
	@RequestMapping("/activate")
	public String viewActivate() {
		return "signup/signup-activate";
	}

}
